ppt = load('D:\Manoj\tsunami\20110311_Japan\ppt20110311vmin.txt');
ppt_z = ppt(:,3);
fday =datenum(2011,03,11,00,00,00):(1/(24*60)):datenum(2011,03,11,23,59,59);
b1 = min(fday):(0.1/24):max(fday);
sp=spline(b1,ppt_z(:)'/spline(b1,eye(length(b1)),fday(:)'));
ppt_z_f = ppt_z'-ppval(fday,sp);
%plot(fday,ppt_z_f-6);
%datetick
%hold;

gua = load('D:\Manoj\tsunami\20110311_Japan\HON_GUA_1sec\HON_GUA\GUA2011070.sec');
gua_z = gua(:,4)./100;
fday_s = datenum(2011,03,11,00,00,00):(1/(24*3600)):datenum(2011,03,11,23,59,59);
b1_s = min(fday_s):(0.1/24):max(fday_s);
sp=spline(b1_s,gua_z(:)'/spline(b1_s,eye(length(b1)),fday_s(:)'));
gua_z_f = gua_z'-ppval(fday_s,sp);

hon = load('D:\Manoj\tsunami\20110311_Japan\HON_GUA_1sec\HON_GUA\HON2011070.sec');
hon_z = gua(:,4)./100;
sp=spline(b1_s,hon_z(:)'/spline(b1_s,eye(length(b1)),fday_s(:)'));
hon_z_f = hon_z'-ppval(fday_s,sp);

% gua = load('D:\Manoj\tsunami\20110311_Japan\gua.txt');
% gua_z_m = gua(:,3);
% sp=spline(b1,gua_z_m(:)'/spline(b1,eye(length(b1)),fday(:)'));
% gua_z_m_f = gua_z_m'-ppval(fday,sp);
% hold on;
% plot(fday,gua_z_m_f,'r');
% hon = load('D:\Manoj\tsunami\20110311_Japan\hon.txt');
% hon_z = hon(:,3);
% sp=spline(b1,hon_z(:)'/spline(b1,eye(length(b1)),fday(:)'));
% hon_z_f = hon_z'-ppval(fday,sp);
% plot(fday,hon_z_f,'g');

%1 sec data 
ipm = load('D:\Manoj\tsunami\20110311_Japan\ipm20110311_xyz.txt');
ipm_z = ipm(:,3);
% fday_s = datenum(2011,03,11,00,00,00):(1/(24*3600)):datenum(2011,03,11,23,59,59);
% b1_s = min(fday_s):(0.1/24):max(fday_s);
sp=spline(b1_s,ipm_z(:)'/spline(b1,eye(length(b1)),fday_s(:)'));
ipm_z_f = ipm_z'-ppval(fday_s,sp);
%plot(fday_s,ipm_z_f+2,'r');

%estimated tsunami arrival times
%%
%%GUA HON PPT IPM

arrival_time = [3 + 28/60, 7 + 32/60, 11 + 22/60 , 16 + 58/60] ./24 + datenum(2011,03,11, 05,46,23); 


plot(fday_s,gua_z_f-12,'r');
hold on;
set(gca,'FontSize',16);
plot(fday_s,hon_z_f-6,'g');
plot(fday,ppt_z_f);
plot(fday_s,ipm_z_f+6,'k');
datetick('x','keeplimits');
grid on;
legend('GUA','HON','PPT','IPM');

line([arrival_time(1),arrival_time(1)], [-10,-14],'color','c','LineWidth',4);
line([arrival_time(2),arrival_time(2)], [-4,-8],'color','c','LineWidth',4);
line([arrival_time(3),arrival_time(3)], [-2,2],'color','c','LineWidth',4);
line([arrival_time(4),arrival_time(4)], [4,8],'color','c','LineWidth',4);

